package com.google.code.p.ivans;

import java.io.IOException;
import java.sql.SQLException;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cafe.ejb.WaiterService;
import cafe.ejb.myexceptions.EntityNotFoundException;

public class RemoveWaiter extends HttpServlet {	
   
	private static final long serialVersionUID = -151791133052905445L;
	
	@EJB 
	private WaiterService waiterSI;

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		try {
			waiterSI.removeByID(Integer.valueOf(request.getParameter("id")));
			
			RequestDispatcher requestDispatcher = request.getRequestDispatcher("waiters.jsp");
			requestDispatcher.forward(request, response);
			
		} catch (NumberFormatException e) {
			
		} catch (EntityNotFoundException e) {
			
		} catch (SQLException e) {
			
		}
	}

}
